package com.bw.zg3.Cate.WX

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil.ItemCallback
import androidx.recyclerview.widget.RecyclerView
import com.bw.base.entity.WXEntityResultItem
import com.bw.zg3.R
import com.bw.zg3.databinding.WxBinding

class WXApter:PagingDataAdapter<WXEntityResultItem,WXApter.WxViewHodel>(WX) {
    companion object{
        val WX=object :ItemCallback<WXEntityResultItem>(){
            override fun areItemsTheSame(
                oldItem: WXEntityResultItem,
                newItem: WXEntityResultItem,
            ): Boolean {
              return oldItem==newItem
            }

            override fun areContentsTheSame(
                oldItem: WXEntityResultItem,
                newItem: WXEntityResultItem,
            ): Boolean {
              return oldItem.id==newItem.id
            }

        }
    }
    class WxViewHodel(view: View):RecyclerView.ViewHolder(view){
       val  binding=DataBindingUtil.bind<WxBinding>(view)

    }
    override fun onBindViewHolder(holder: WXApter.WxViewHodel, position: Int) {
       holder.binding?.wx=getItem(position)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WXApter.WxViewHodel {
        val inflate = LayoutInflater.from(parent.context).inflate(R.layout.wx, parent, false)
        return WxViewHodel(inflate)
    }

}